import Button from "components/Base/Button";
import Icon from "components/Base/Icon";
import DataTable from "components/Base/DataTable";
import Image from "components/Base/Image";
import {size} from "store2";
import {memberLevelDict} from "../../../../models/MemberLevel";

export default (self) => [

  {
    title: 'id',
    name: 'id',
    tableItem: {
    },
    formItem: {
      type: 'hidden',
    }
  },

  {
    title: '会员等级',
    name: 'memberLevel',
    tableItem: {},
    formItem: {
      rules: [
        {
          required: true,
          message: '请选择会员等级'
        }
      ],

      showSearch: true,
      type: 'select',
    },
    dict: memberLevelDict,
  },

  {
    title: '会员时长(天)',
    name: 'durationDay',
    tableItem: {
    },
    formItem: {
      rules: [
        {
          required: true,
          message: '请输入会员时长'
        }
      ],
      type: 'number'
    },
  },

  {
    title: '商品名称',
    name: 'name',
    tableItem: {
    },
    formItem: {
      rules: [
        {
          required: true,
          message: '请输入商品名称'
        }
      ]
    },
  },
  {
    title: '商品图片',
    name: 'pic',
    tableItem: {
      render: (text, record) => {
        return <Image src={text} style={{width:50, height:50}}/>
      }
    },
    formItem: {
      type: 'upload',
      listType: 'picture',
      max: 1,
      rules: [
        {
          required: true,
          message: '请上传商品图片'
        }
      ]
    }
  },

  {
    title: "小标题",
    name: 'subName',
    tableItem: {
    },
    formItem: {
    },
  },

  {
    title: '商品描述',
    name: 'description',
    tableItem: {
      render: (text, record) => {
        return (
          <DataTable.Oper>
            <a onClick={e => {
              self.props.showGoodEditor(record.goodId, record.description);
            }}>
              <span>点击编辑描述</span>
            </a>
          </DataTable.Oper>
        );
      }
    },
  },

  {
    title: '商品规格',
    name: 'goodsItem',
    tableItem: {
      render: (text, record) => {

        return (
          <DataTable.Oper>
            <a onClick={e => {
              self.props.showGoodItem(record.goodId);
            }}>
              <span>编辑规格</span>
            </a>
          </DataTable.Oper>
        );
      }
    },
  },

  {
    title: '操作',
    tableItem: {
      width: 180,
      align: 'center',
      render: (text, record) => (
        <DataTable.Oper>
          <Button tooltip="修改" onClick={e => self.onUpdate(record)}>
            <Icon type="edit"/>
          </Button>
          <Button tooltip="删除" onClick={e => self.onDelete(record)}>
            <Icon type="trash"/>
          </Button>
        </DataTable.Oper>
      )
    }
  }
]
